<?php
$servers =array('s1.radioheart.ru'=>'s1.radioheart.ru',
                's2.radioheart.ru'=>'s2.radioheart.ru',
                's3.radioheart.ru'=>'s3.radioheart.ru',
                's4.radioheart.ru'=>'s4.radioheart.ru',
                's5.radioheart.ru'=>'s5.radioheart.ru',
                's6.radioheart.ru'=>'s6.radioheart.ru',
                's7.radioheart.ru'=>'s7.radioheart.ru');
$statuses=array('Новый','Не оплачен','Активен');
?>
<div class="billing_admin">
    <div class="billing_admin_find_form">
        Найти заказ:
        <table>
            <tr>
                <td><?php echo $this->Form->create('Order',array('action' => 'admin_find')); ?></td>
                <td><?php echo $this->Form->input('id',array(
                                                             'type'=>'text',
                                                             'class'=>'text',
                                                             'label'=>'ID'
                                                             )); ?>
                </td>
                <td><?php echo $this->Form->input('login',array(
                                                                'type'=>'text',
                                                                'class'=>'text',
                                                                'label'=>'Пользователь'
                                                                )); ?>
                </td>
                <td><?php echo $this->Form->input('serverip',array(
                                                                   'class'=>'text',
                                                                   'label'=>'Сервер',
                                                                   'options' => $servers,
                                                                   'empty' => '(Выберите сервер)'
                                                                   )); ?>
                </td>
                <td><?php echo $this->Form->input('status',array(
                                                                   'class'=>'text',
                                                                   'label'=>'Статус',
                                                                   'options' => $statuses,
                                                                   'empty' => '(Выберите статус)'
                                                                   )); ?>
                </td>
                <td><?php echo $this->Form->end(__('Найти')); ?></td>
            </tr>
        </table>
    </div>
<?
echo ("<table border ='1' class='data-table'>");
echo ("<tr>
        <td><b>".$this->Paginator->sort('id','ID')."</b></td>
        <td><b>Юзер</b></td>
        <td><b>Тариф</b></td>
        <td><b>AutoDJ</b></td>
        <td><b>".$this->Paginator->sort('serverip','Сервер IP')."</b></td>
        <td><b>Порт</b></td>
        <td><b>".$this->Paginator->sort('oplachenodo','Оплачено')."</b></td>
        <td><b>".$this->Paginator->sort('status','Статус')."</b></td>
        <td><b>Управление</b></td>
      </tr>");
//echo '<pre>';
foreach($orders as $order_integrated)
{
    $order=$order_integrated['Order'];
    $user=$order_integrated['User'];
    $uslogin=$user['login'];
    $uid=$user['id'];
    $opl=$order['oplachenodo'];
    if($opl==0)
      $opl="<b>Не оплачено</b>";
    else
      $opl=date("d.m.Y",$opl);
    switch($order['status'])
    {
        case '0': $status="<img src='http://radioheart.ru/billing/modules/billing/img/error.png'>"; break;
        case '1': $status="<img src='http://radioheart.ru/billing/modules/billing/img/unpaid.png'>"; break;
        case '2': $status="<img src='http://radioheart.ru/billing/modules/billing/img/ok.png'>";break;
    }
    echo("<tr class='even'>
         <td>".$order['id']."</td>
         <td><a href='http://".$_SERVER['SERVER_NAME']."/billing/users/edit/$uid'>$uslogin</a><br />
         <a href='/billing/admin/balances/edit/$uid' target='_blank'>Баланс</a> /
         <a href='http://".$_SERVER['SERVER_NAME']."/billing/admin/tickets/index/$uid'>Тикеты</a></td>
         <td>".$order['tarif']."</td>
         <td>".$order['autodjspace']." GB</td>
         <td>".$order['serverip']."</td>
         <td>".$order['port']."</td>
         <td>$opl</td>
         <td>$status</td>
         <td><!--<a href='/billing/admin/orders/view/".$order['id']."'>
                <img src='http://radioheart.ru/billing/modules/billing/img/view.png'></a>-->
            <a href='/billing/admin/orders/edit/".$order['id']."' title='Редактировать'>
                <img src='http://radioheart.ru/billing/modules/billing/img/edit.png'></a>
             <a href='/billing/admin/orders/delete/".$order['id']."' title='Удалить' onClick=\"return window.confirm('Вы действительно хотите удалить этот заказ?')\"><img src='http://radioheart.ru/billing/modules/billing/img/delete.png'></a></td>
         </tr> ");
}
echo "</table>";
// Shows the page numbers
echo $this->Paginator->numbers();
echo "<br>";
// Shows the next and previous links
echo $this->Paginator->prev(
  '« Назад ',
  null,
  null,
  array('class' => 'disabled')
);
echo $this->Paginator->next(
  ' Вперед » ',
  null,
  null,
  array('class' => 'disabled')
);

// prints X of Y, where X is current page and Y is number of pages
echo $this->Paginator->counter();
//echo '</pre>';
?>

</div>
<div class="actions">
	<h3><?php echo __d('cake', 'Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')); ?></li>
<?php
		$done = array();
		foreach ($associations as $_type => $_data) {
			foreach ($_data as $_alias => $_details) {
				if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
					echo '<li>';
					echo $this->Html->link(
						__d('cake', 'List %s', Inflector::humanize($_details['controller'])),
						array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'index')
					);
					echo '</li>';

					echo '<li>';
					echo $this->Html->link(
						__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))),
						array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'add')
					);
					echo '</li>';
					$done[] = $_details['controller'];
				}
			}
		}
?>
	</ul>
</div>